package com.industrial.app.controller.formal;


import com.industrial.app.domain.formal.FourGyPowerFormal;
import com.industrial.app.service.IFourGyPowerFormalService;
import com.industrial.common.core.utils.poi.ExcelUtil;
import com.industrial.common.core.web.controller.BaseController;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 4省工业用电Controller
 *
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/biz/power/zdsyd/formal")
public class FourGyPowerFormalController extends BaseController
{
    @Autowired
    private IFourGyPowerFormalService fourGyPowerFormalService;

    /**
     * 查询4省工业用电列表
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:list')")
    @GetMapping("/list")
    public TableDataInfo list(FourGyPowerFormal fourGyPowerFormal)
    {
        startPage();
        List<FourGyPowerFormal> list = fourGyPowerFormalService.selectFourGyPowerFormalList(fourGyPowerFormal);
        return getDataTable(list);
    }

    /**
     * 导出4省工业用电列表
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:export')")
//    @Log(title = "4省工业用电", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FourGyPowerFormal fourGyPowerFormal)
    {
        List<FourGyPowerFormal> list = fourGyPowerFormalService.selectFourGyPowerFormalList(fourGyPowerFormal);
        ExcelUtil<FourGyPowerFormal> util = new ExcelUtil<FourGyPowerFormal>(FourGyPowerFormal.class);
        util.exportExcel(response, list, "4省工业用电数据");
    }

    /**
     * 获取4省工业用电详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:query')")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(fourGyPowerFormalService.selectFourGyPowerFormalByBaseId(baseId));
    }

    /**
     * 新增4省工业用电
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:add')")
//    @Log(title = "4省工业用电", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FourGyPowerFormal fourGyPowerFormal)
    {
        return toAjax(fourGyPowerFormalService.insertFourGyPowerFormal(fourGyPowerFormal));
    }

    /**
     * 修改4省工业用电
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:edit')")
//    @Log(title = "4省工业用电", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FourGyPowerFormal fourGyPowerFormal)
    {
        return toAjax(fourGyPowerFormalService.updateFourGyPowerFormal(fourGyPowerFormal));
    }

    /**
     * 删除4省工业用电
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:remove')")
//    @Log(title = "4省工业用电", businessType = BusinessType.DELETE)
    @DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(fourGyPowerFormalService.deleteFourGyPowerFormalByBaseIds(baseIds));
    }
}
